/**
 * Handle image loading error by setting fallback image
 * @param event - The error event from img element
 * @param fallbackSrc - The fallback image source, defaults to '/images/no.jpg'
 */
export function handleImageError(event: Event, fallbackSrc: string = '/images/no.jpg') {
  const img = event.target as HTMLImageElement
  if (img && img.src !== fallbackSrc) {
    img.src = fallbackSrc
  }
}

/**
 * Get image source with fallback
 * @param src - The original image source
 * @param fallbackSrc - The fallback image source, defaults to '/images/no.jpg'
 * @returns The image source or fallback
 */
export function getImageSrc(src: string | null | undefined, fallbackSrc: string = '/images/no.jpg'): string {
  return src || fallbackSrc
} 